<style type="text/css">
	#global_content{
		width: 1235px;
	}
</style>
<h2>
  <?php echo $this->translate("Webmix Plugin") ?>
</h2>

<?php if( count($this->navigation) ): ?>
  <div class='tabs'>
    <?php
      // Render the menu
      //->setUlClass()
      echo $this->navigation()->menu()->setContainer($this->navigation)->render()
    ?>
  </div>
<?php endif; ?>

<p>
  <?php echo $this->translate('') ?>
</p>

<br />

<script type="text/javascript">
  var currentOrder = '<?php echo $this->order ?>';
  var currentOrderDirection = '<?php echo $this->order_direction ?>';
  var changeOrder = function(order, default_direction){
    // Just change direction
    if( order == currentOrder ) {
      $('order_direction').value = ( currentOrderDirection == 'ASC' ? 'DESC' : 'ASC' );
    } else {
      $('order').value = order;
      $('order_direction').value = default_direction;
    }
    $('filter_form').submit();
  }

    function multiModify()
    {
      var multimodify_form = $('multimodify_form');
      if (multimodify_form.submit_button_delete.value == 'delete')
      {
        return confirm('<?php echo $this->string()->escapeJavascript($this->translate("Are you sure you want to DELETE the selected companies?")) ?>');
      }
    }
    
    function selectAll()
    {
      var i;
      var multimodify_form = $('multimodify_form');
      var inputs = multimodify_form.elements;
      for (i = 1; i < inputs.length - 1; i++) {
        if (!inputs[i].disabled) {
          inputs[i].checked = inputs[0].checked;
        }
      }
    }
    
    function SubmitForm(type)
    {       
       if(type == 'delete'){
            $('submit_button_delete').set('value','delete');
            url = action="<?php echo $this->url(array('action'=>'multi-modify'));?>";               
            document.companyForm.action = url;        
            document.companyForm.submit();
       } 
       if(type == 'merge'){
            $('submit_button_merge').set('value','merge');
            var href = en4.core.baseUrl + 'admin/webmix/company/merge';
            console.log(href);
            //this.Smoothbox.open(href);
            document.companyForm.action = href;        
            document.companyForm.submit();                        
       }
       return false;
    }
</script>

<div class='admin_search'>
  <?php echo $this->formFilter->render($this) ?>
</div>

<br />

 <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'webmix', 'controller' => 'album', 'action' => 'create'), $this->translate('Add New Album'), array(
      'class' => 'buttonlink',
      'style' => 'background-image: url(' . $this->layout()->staticBaseUrl . 'application/modules/Core/externals/images/admin/new_category.png);')) ?>
      <br />
<div class='admin_results'>
  <div>
    <?php $count = $this->paginator->getTotalItemCount() ?>
    <?php echo $this->translate(array("%s companies found", "%s companies found", $count),
        $this->locale()->toNumber($count)) ?>
  </div>
  <div>
    <?php echo $this->paginationControl($this->paginator, null, null, array(
      'pageAsQuery' => true,
      'query' => $this->formValues,
      //'params' => $this->formValues,
    )); ?>
  </div>
</div>

<br />
    <!-- <a href='<?php echo $this->url(array('action' => 'index', 'track' => '1'));?>'>
        <?php echo $this->translate("Show Tracked Company") ?>
    </a> -->

<br />

<div class="admin_table_form">
<form id='multimodify_form' name="companyForm" method="post">
  <table class='admin_table' style="width:100%">
    <thead>
      <tr>
        <th ><input onclick="selectAll()" type='checkbox' class='checkbox'></th>
        <th ><a href="javascript:void(0);" onclick="javascript:changeOrder('company_id', 'ASC');"><?php echo $this->translate("ID") ?></a></th>
        <th class="admin_table_centered" ><?php echo $this->translate('Logo');?></th>
        <th><a href="javascript:void(0);" onclick="javascript:changeOrder('title', 'ASC');"><?php echo $this->translate("Title") ?></a></th>
        <th ><?php echo $this->translate("Key") ?></th>
        <th class="" ><?php echo $this->translate('Owner');?></th>
        <th style=''><a href="javascript:void(0);" onclick="javascript:changeOrder('add_count', 'DESC');"><?php echo $this->translate('Added');?></th>
        <th style=''><a href="javascript:void(0);" onclick="javascript:changeOrder('click_count', 'DESC');"><?php echo $this->translate('Click');?></th>
        <th  class='admin_table_options'><?php echo $this->translate("Options") ?></th>
      </tr>
    </thead>
    <tbody>
      <?php if( count($this->paginator) ): ?>
        <?php foreach( $this->paginator as $item ):?>
          <tr>
            <td><input name='modify_<?php echo $item->getIdentity();?>' value=<?php echo $item->getIdentity();?> type='checkbox' class='checkbox'></td>
            <td><?php echo $item->musicalbum_id ?></td>
            <td><img src="<?php echo $item->getPhotoUrl('thumb.normal');?>"></td>
            <td class=''><?php echo $item->title?></td>
            <td class=''>
             	<?php echo $item->key;?>
            </td>
            
            <td><?php echo $item->getOwner()->__toString();?></td>
            <td><?php if (empty($item->add_count)) echo "0"; else   echo $item->add_count?>               
                </td>
            <td><?php echo $item->click_count?>               
                </td>
            <!--<td><?php echo ($item->approve)? $this->translate('Yes'):$this->translate('Not Yet');?></td>
            -->
           
            <td class='admin_table_options'>
            	<!-- <?php if($item->approve):?>
	              <a class='smoothbox' href='<?php echo $this->url(array('action' => 'approve', 'company' => $item->getIdentity(), 'approve' => 0));?>'>
	                <?php echo $this->translate("Un-Approve") ?>
	              </a>
              	<?php else:?>
              		<a class='smoothbox' href='<?php echo $this->url(array('action' => 'approve', 'company' => $item->getIdentity(),'approve' => 1));?>'>
	                <?php echo $this->translate("Approve") ?>
	              </a>
              	<?php endif;?>
				| 	-->
             		
              <a class='smoothbox' href='<?php echo $this->url(array('module' => 'webmix', 'controller' => 'album','action' => 'edit', 'id' => $item->getIdentity()),'default');?>'>
                <?php echo $this->translate("edit") ?>
              </a>
				| 
                <a class='smoothbox' href='<?php echo $this->url(array( 'module' => 'webmix', 'controller' => 'album', 'action' => 'delete', 'id' => $item->getIdentity()), 'admin_default', true);?>'>
                  <?php echo $this->translate("delete") ?>
                </a>
				<!--| 
            	<?php if($item->track):?>
	              <a class='smoothbox' href='<?php echo $this->url(array('action' => 'track', 'company' => $item->getIdentity(), 'track' => 0));?>'>
	                <?php echo $this->translate("Un-Track") ?>
	              </a>
              	<?php else:?>
              		<a class='smoothbox' href='<?php echo $this->url(array('action' => 'track', 'company' => $item->getIdentity(),'track' => 1));?>'>
	                <?php echo $this->translate("Track") ?>
	              </a>
              	<?php endif;?>
                 -->                

            </td>
          </tr>
        <?php endforeach; ?>
      <?php endif; ?>
    </tbody>
  </table>
  <br />
  

  
  
  <br/>
   <?php echo $this->htmlLink(array('route' => 'admin_default', 'module' => 'webmix', 'controller' => 'album', 'action' => 'create'), $this->translate('Add New Album'), array(
      'class' => 'buttonlink',
      'style' => 'background-image: url(' . $this->layout()->staticBaseUrl . 'application/modules/Core/externals/images/admin/new_category.png);')) ?>
</form>
</div>
<br/>

<div class='admin_results'>
  <div>
    <?php $count = $this->paginator->getTotalItemCount() ?>
    <?php echo $this->translate(array("%s album found", "%s albums found", $count),
        $this->locale()->toNumber($count)) ?>
  </div>
  <div>
    <?php echo $this->paginationControl($this->paginator, null, null, array(
      'pageAsQuery' => true,
      'query' => $this->formValues,
      //'params' => $this->formValues,
    )); ?>
  </div>
</div>